package com.leoandroid.tool.toolsbox.largeread.activity;

import android.os.Bundle;
import android.widget.ImageView;
import android.widget.LinearLayout;

import androidx.constraintlayout.widget.ConstraintLayout;

import com.leoandroid.tool.toolsbox.largeread.R;

public class MultiLightActivity extends BaseActivity{

    private LinearLayout layoutClose;
    private ImageView imgRed;
    private ImageView imgYellow;
    private ImageView imgCyan;
    private ImageView imgPurple;
    private ImageView imgBlue;
    private ImageView imgOrange;
    private ImageView imgGreen;
    private ImageView imgCurSelected;
    private ConstraintLayout layoutMulti;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_multi_light);
        initView();
    }

    private void initView(){
        layoutClose = findViewById(R.id.layout_close);
        layoutMulti = findViewById(R.id.multi_layout);
        imgRed = findViewById(R.id.type_red);
        imgYellow = findViewById(R.id.type_yellow);
        imgCyan = findViewById(R.id.type_cyan);
        imgPurple = findViewById(R.id.type_purple);
        imgBlue = findViewById(R.id.type_blue);
        imgOrange = findViewById(R.id.type_orange);
        imgGreen = findViewById(R.id.type_green);


        layoutClose.setOnClickListener(view -> {
            finish();
        });
        imgCurSelected = imgRed;
        imgRed.setOnClickListener(view -> {
            setCurResource(imgRed);
            layoutMulti.setBackgroundColor(getResources().getColor(R.color.color_ff0000));
        });
        imgYellow.setOnClickListener(view -> {
            setCurResource(imgYellow);
            layoutMulti.setBackgroundColor(getResources().getColor(R.color.color_ffff00));
        });
        imgCyan.setOnClickListener(view -> {
            setCurResource(imgCyan);
            layoutMulti.setBackgroundColor(getResources().getColor(R.color.color_00ffff));
        });
        imgPurple.setOnClickListener(view -> {
            setCurResource(imgPurple);
            layoutMulti.setBackgroundColor(getResources().getColor(R.color.color_8b00ff));
        });
        imgBlue.setOnClickListener(view -> {
            setCurResource(imgBlue);
            layoutMulti.setBackgroundColor(getResources().getColor(R.color.color_0000ff));
        });
        imgOrange.setOnClickListener(view -> {
            setCurResource(imgOrange);
            layoutMulti.setBackgroundColor(getResources().getColor(R.color.color_ff7f00));
        });
        imgGreen.setOnClickListener(view -> {
            setCurResource(imgGreen);
            layoutMulti.setBackgroundColor(getResources().getColor(R.color.color_00ff00));
        });
    }

    private void setCurResource(ImageView selectView){
        imgCurSelected.setBackgroundResource(R.drawable.bg_oval_black);
        imgCurSelected = selectView;
        selectView.setBackgroundResource(R.drawable.bg_oval_white);
    }
}
